#ifndef YIGSYNTH_H
#define YIGSYNTH_H

// System includes
#include <QString>

// Local includes
//#include "sc++/synth.h"
#include "Node.h"
#include "graphics/yigsynthgraphic.h"

/**
*   YigSynth is the class for storing and manipulating the interface synth instances
*/
class YigSynth : public QObject
{
    Q_OBJECT

public:

    /**
    *   YigSynth constructor
    *   @param Synth* synth pointer to the synth this YigSynth encapsulates
    *   @param QString key for the map in the parent YigNetworkChannel
    */
    YigSynth(sc::Synth* synth, QString key, int audioInBus = 24, int audioOutBus = 20, int modInBus = 24);

    /**
    * YigSynth deconstructor. Cleans up synth memory
    */
    ~YigSynth();

    /**
    *   Returns this YigSynth's map key for the parent YigNetworkChannel
    *   @return QString key for the parent map
    */
    QString getKey();

    /**
    *   getAudioInBus returns the audio input bus for this synth on the sc synth server
    *   @return int the audio input bus
    */
    int getAudioInBus();

    /**
    *   getAudioOutBus returns the audio output bus for this synth on the sc synth server
    *   @return int the audio output bus
    */
    int getAudioOutBus();

    /**
    *   getModInBus returns the mod input bus for this synth on the sc synth server
    *   @return int the mod input bus
    */
    int getModInBus();

    QString getSynthDefName();

    /** free's this synth on the server */
    void free();

public slots:

    /**
    *   setParam1 Set this YigSynth's first parameter
    *   @param float param1 The new value to which the first parameter is assigned
    */
    void setParam1(float param1);

    /**
    *   setParam2 Set this YigSynth's second parameter
    *   @param float param2 The new value to which the second parameter is assigned
    */
    void setParam2(float param2);

    /**
    *   called when a parameter for a synth has changed
    *   @param QString mapKey The key for the synth that has changed
    *   @param YigSynthGraphic::ParamType The type of parameter (param1 or param2)
    *   @param float The new value for the parameter
    */
    void setParam(QString mapKey, YigSynthGraphic::ParamType paramType, float value);

    /**
    *   setAudioInBus Sets the audio input bus for this synth on the SCSynth server
    *   @param int audioInBus the new bus number
    */
    void setAudioInBus(int audioInBus);

    /**
    *   setAudioOutBus Sets the audio output bus for this synth on the SCSynth server
    *   @param int audioOutBus the new bus number
    */
    void setAudioOutBus(int audioOutBus);

    /**
    *   setModInBus Sets the mod input bus for this synth on the SCSynth server
    *   @param int modInBus the new bus number
    */
    void setModInBus(int modInBus);

private:

    /** Key for this instance of YigSynth for the map which is owned by an instance YigNetworkChannel. */
    QString mKey;
    /** pointer to the synth this YigSynth encapsulates */
    sc::Synth* mSynth;
    /** current values of the two modulatable paramaters for this YigSynth */
    float mParam1, mParam2;
    /** buses for ins & outs */
    int mAudioInBus, mAudioOutBus, mModInBus;
};

#endif // YIGSYNTH_H
